package com.example.demo1.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.annotation.Nullable;

import com.example.demo1.R;

public class ActivityA extends Activity {


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_a);
        initWidget();
    }


    private void initWidget() {
        Button button = findViewById(R.id.btn_click);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                //定义一个Intent对象，设置要跳转到的Activity
                Intent intent = new Intent(ActivityA.this, ActivityB.class);

                //携带参数
                intent.putExtra("key", "this is a message");

                //进行跳转
                startActivity(intent);

            }
        });
    }

}
